/*
*******************************************************************************
**
**  This device driver was created by Applilet2 for V850ES/Fx3
**  32-Bit Single-Chip Microcontrollers
**
**  Copyright(C) 2002, 2013 Renesas Electronics Corporation
**  All rights reserved by Renesas Electronics Corporation.
**
**  This program should be used on your own responsibility.
**  Renesas Electronics Corporation assumes no responsibility for any losses
**  incurred by customers or third parties arising from the use of this file.
**
**  Filename :	serial_user.c
**  Abstract :	This file implements device driver for Serial module.
**  APIlib :	Applilet2 for V850ES/Fx3 V2.43 [30 Mar 2011]
**
**  Device :	uPD70F3376
**
**  Compiler :	CA850
**
**  Creation date:	2013-05-09
**  
*******************************************************************************
*/

//#pragma interrupt INTCB1R MD_INTCB1R
/*
*******************************************************************************
**  Include files
*******************************************************************************
*/
#include "macrodriver.h"
#include "serial.h"
/* Start user code for include definition. Do not edit comment generated here */
/* End user code for include definition. Do not edit comment generated here */
#include "user_define.h"

/*
*******************************************************************************
**  Global define
*******************************************************************************
*/
extern volatile UCHAR*	gpCsib1RxAddress;	/* CSIB1 receive buffer address */
extern volatile USHORT	gCsib1RxLen;	/* CSIB1 receive data length */
extern volatile USHORT	gCsib1RxCnt;	/* CSIB1 receive data count */
extern volatile UCHAR*	gpCsib1TxAddress;	/* CSIB1 send buffer address */
extern volatile USHORT	gCsib1TxLen;	/* CSIB1 send data length */
extern volatile USHORT	gCsib1TxCnt;	/* CSIB1 send data count */
/* Start user code for global definition. Do not edit comment generated here */
/* End user code for global definition. Do not edit comment generated here */


/*
**-----------------------------------------------------------------------------
**
**	Abstract:
**		This function is INTCB1R interrupt service routine.
**
**	Parameters:
**		None
**
**	Returns:
**		None
**
**-----------------------------------------------------------------------------
*/

/*
__interrupt void MD_INTCB1R(void)
{
	if (CB1CTL2 != CSIB_DATA_LENGTH_8)
	{

		*(USHORT*)gpCsib1RxAddress = CB1RX;
		gpCsib1RxAddress += 2;
		gCsib1RxCnt += 2;
	}
	else
	{

		*gpCsib1RxAddress = CB1RXL;
		gpCsib1RxAddress ++;
		gCsib1RxCnt ++;
	}
	if (gCsib1RxCnt == gCsib1TxLen)
	{
		CSIB1_ReceiveEndCallback();
	}
	else
	{
	
	}

	if (gCsib1TxCnt > 0)
	{
		if (CB1CTL2 != CSIB_DATA_LENGTH_8)
		{
		
			CB1TX = *(USHORT* )gpCsib1TxAddress;	
			gpCsib1TxAddress += 2;
			gCsib1TxCnt -= 2;
		}
		else
		{
		
			CB1TXL = *gpCsib1TxAddress;	
			gpCsib1TxAddress++;
			gCsib1TxCnt--;
		}		
	}
	else
	{
		CSIB1_SendEndCallback();	
	}
}
*/
/*
**-----------------------------------------------------------------------------
**
**	Abstract:
**		This function is a callback function of CSIB1.
**
**	Parameters:
**		None
**
**	Returns:
**		None
**
**-----------------------------------------------------------------------------
*/
void CSIB1_ReceiveEndCallback(void)
{
	/* Start user code. Do not edit comment generated here */
	
	/* End user code. Do not edit comment generated here */
}

/*
**-----------------------------------------------------------------------------
**
**	Abstract:
**		This function is a callback function of CSIB1.
**
**	Parameters:
**		None
**
**	Returns:
**		None
**
**-----------------------------------------------------------------------------
*/
void CSIB1_SendEndCallback(void)
{
	/* Start user code. Do not edit comment generated here */
	
	/* End user code. Do not edit comment generated here */
}

/* Start adding user code. Do not edit comment generated here */
/* End user code adding. Do not edit comment generated here */

/**
* @brief  Local functions        .                     
*/
